package com.example.demo.controller;

import com.example.demo.entity.Article;
import com.example.demo.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {


    @GetMapping("/hello")
    public String hello() {
        int a = 1/0;
        return "hello";
    }

    @PostMapping("/test")
    public String test() {
        return "test";
    }

    @Autowired
    ArticleService articleService;

    @GetMapping("/findById/{id}")
    public Article test1(@PathVariable Integer id) {
       return articleService.findById(id);
    }
}
